<template>
  <div>
    <!--面包屑导航区域-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!--卡片视图-->
    <el-card>
      <el-table :data="rightsList" border stripe>
        <el-table-column type="index" label="ID"></el-table-column>
        <el-table-column prop="psName" label="权限名称"></el-table-column>
        <el-table-column prop="psC" label="路径"></el-table-column>
        <el-table-column prop="psLevel" label="权限等级">
          <template v-slot="scope">
            <el-tag v-if="scope.row.psLevel == 0">一级</el-tag>
            <el-tag v-else-if="scope.row.psLevel == 1" type="success">二级</el-tag>
            <el-tag v-else type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
    export default {
        name: "Rights",
      data(){
          return{
            rightsList:[]
          }
      },
      //初始化加载列表
      created() {
          this.getRightsList();
      },
      //自定义方法
      methods:{
          //获取权限列表
          async getRightsList(){
            const {data:res} = await this.$axios.get("rights/list");

            if(res.code != 200 ){
              this.$message.error("获取权限列表失败");
            }
            this.rightsList = res.data.rights;
            console.log(this.rightsList);
          }
      }

    }
</script>

<style scoped>
.el-card{
  margin-top: 15px;
}
</style>
